<%@ page contentType="text/html;charset=utf-8" 
    import="java.util.*,com.zh.User,com.zh.UserBean,com.zh.Util,org.springframework.web.context.*,com.zh.House,org.springframework.web.context.support.*"
%>    
<%
    	List<User> userlist = (List<User>)request.getAttribute("userlist");
    %>
<html>
  <head>
    <title>个人资料信息查看</title>
	<link rel=stylesheet href="css/general.css" type="text/css">
    <script language="JavaScript" src="script/com.js"></script>
    <script language="JavaScript">
      function check(){
      	var key = document.all.keywords.value.trim();
      	if(key==""){
			alert("关键字为空,请重新输入!!!");
			return;
      	}
      	document.all.smf.submit();
      }
      function checkPage(temp){
      	var page = document.all.page.value.trim();
  		var reg = /^[1-9][0-9]*$/;
		if((reg.test(page.trim()))&&(page<=temp)){
			document.all.mf.submit();
		}
		else{
			alert("输入不合法,请重新输入!!!");
			return;
		}
      }
    </script>
     <style>
	       .mima {
	       width:100%;
	       height:40px;
	       background-color:#ADD8E6;
	       }
	       .zi {
	       font-size:20px;
	       position:relative;
	       left:45%;
	       margin-left:-30px;
	       line-height:40px;
	       }
	</style>
  </head>
  <body>
  	<jsp:useBean id="userBean" class="com.zh.UserBean" scope="session"/>
		<div class="mima"><font class="zi">个人资料信息</font></div><br>
	<% 
		if(userlist.isEmpty()){
			out.println("<br/><br/><br/><center><h2>没有搜索到你要的商品!!!</h2></center>");
		}
		else{
		
	 %>
	<table width="90%" border="0" cellspacing="1" style="background-color:#000000" align="center">
	  <tr  bgcolor="#ADD8E6" align="center">	    
	    
	    <th>业主姓名</th>
	  	<th>性别</th>
	  	<th>职业</th>
	  	<th>电话</th>
	  	<th>入住时间</th>
	  	<th>入住人口</th>
	  	<th>房屋地址</th>
	  	
	  </tr>
	<%
		//获取WebApplicationContext
		WebApplicationContext w=
		   WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
		Util util = (Util)w.getBean("Util");
		int i = 0;
		for(User u:userlist){
		String userId = u.getUserId();
		String houseId=u.getHouseId();
		House h=(House)util.getObject("house",houseId);
		String name=u.getUsername();
		String sex=u.getUsersex();
		String profession=u.getUserprofession();
		String phone=u.getPhonenumber();
		Date ltime=u.getLivetime();
		int lcont=u.getLivecount();
	
		if(i%2==0){
			i++;
			out.println("<tr bgcolor='white' align='center'>");
		}
		else{
			i++;
			out.println("<tr bgcolor='#ADD8E6' align='center'>");
			
		}
	 %>
	   
	    
	    <td><%= name %></td>
	    <td><%= sex %></td>
	    <td><%= profession %></td>
	    <td><%=phone %></td>
	    <td><%= ltime %></td>
	    <td><%= lcont %></td>
	    <td><%= h.getHouseaddress() %></td>
	    
	  </tr>
	<%
		}
	 %>
	</table>	
	<table width="100%">
	<form method="post" id="mf" action="SuperServlet">
	  <tr>
	    <td align="left">
	      <font size="2">共<%= userBean.getCountpage() %>页&nbsp;&nbsp;当前页:<%= userBean.getCurrentpage() %></font>
	    </td>
	    <td align="right">
	      <% 
	      	if(userBean.getCurrentpage()>1){
	       %>
	      <a href="SuperServlet?action=changePage&pagename=/userlook.jsp&page=<%= userBean.getCurrentpage()-1 %>" target="mainFrame"><img src="img/prev.gif" border="0"/></a>
	      <% 
	      	}
	      	if(userBean.getCurrentpage()<userBean.getCountpage()){
	       %>	       
	      <a href="SuperServlet?action=changePage&pagename=/userlook.jsp&page=<%= userBean.getCurrentpage()+1 %>" target="mainFrame"><img src="img/next.gif" border="0"/></a>
	      <% 
	      	}
	      	else{
	      		out.println("<img src='img/next.gif' style='visibility:hidden'/>");
	      	}
	       %>
	      <font size="2">第<input name="page" id="page" size="2" value="<%= userBean.getCurrentpage() %>" onfocus="document.all.page.value=''"/>页</font>
	      <input type="hidden" name="action" value="changePage" />
	      <input type="hidden" name="pagename" value="/userlook.jsp"/>	    
	    </td>
	    <td width="10">
	      <input type="button" value="跳转" style="cursor:hand" onclick="JavaScript:checkPage(<%= userBean.getCountpage() %>)">
	    </td>
	  </tr>	
	</form>
	</table>
	<% 
		}
	 %>
  </body>
</html>